attribute vec4 vPos; 
attribute vec3 vNormal; 
varying vec4 vColor;
uniform mat4 mvMatrix;
uniform mat4 mvpMatrix;
uniform mat3 normalMatrix;
uniform vec4 lightPos;
const vec4 diff = vec4(1.0, 0.1, 0.1, 1.0);
const vec4 amb = vec4(0.2, 0.0, 0.0, 1.0);
void main (void) 
{ 
  vec4 lightPos = vec4(0.0,0.0,0.0,1);
  //vec3 l = normalize(vec3(mvMatrix * (lightPos - vPos)));
  vec4 ep = mvMatrix * vPos;
  vec3 lvec = vec3(normalize(lightPos - ep));
  vec3 tnorm = normalize(normalMatrix * vNormal);
  //vColor = max(dot(lvec,tnorm),0.0)*diff;
  vec4 diffcomp = max(dot(lvec,tnorm),0.0)*diff;
  vec3 v = normalize(vec3(-ep));
  vec3 h = normalize(lvec + v);
  float s= max(dot(h,tnorm),0.0); 
  s = pow(s,50.0);
  vec4 spec = vec4(1.0,1.0,1.0,1.0) * s;
  vColor = diffcomp + spec + amb;
  gl_Position = mvpMatrix * vPos;
}

